import { GlobalEventMgr } from "../../platform/event/GlobalEventMgr";
import { IScript } from "../IScript";
import { Msg_Login_Resp, Msg_Resp } from "../msgs";
import { MsgTypes } from "../MsgTypes";
import { script } from "../NetManager";
import { SyncDemoEvent } from "../SyncDemoEvent";
import { PlayerState } from "../types";

@script()
export class PlayerStateUpdateScript implements IScript<PlayerState[]> {
    getType(): string {
        return MsgTypes.PlayerStateUpdate;
    }
    handle(msg: Msg_Resp<PlayerState[]>): void {

        if(!msg.data || msg.data.length<=0) return;

        GlobalEventMgr.ins.emit(SyncDemoEvent.PlayerStateUpdate, msg.data);
    }
}